package cn.sinjet.model.carsystem;

import com.mgroup.wazehelper.R;

import android.util.Log;
import cn.sinjet.viewmodel.ViewEvent;
import cn.sinjet.viewmodel.ViewModel;

public class RadarModule {
	 CarModel modules;
	 final String tag = RadarModule.class.getSimpleName();
     public RadarModule(CarModel carModel){
    	 modules = carModel;
     }
     public void onViewClk(ViewEvent viewEvent){
    	 switch(viewEvent.getTag()){
    	 case R.id.radar_back:
    		 ViewModel.getIns().finishActivity();
    		 break;
    	 case R.id.radar_test:
             onClkMonitorRadarData();		 
    		 break;
    	 }
     }
     
     int frontLeft = 1;
	 int frontLeftMid = 1;
	 int frontRightMid = 1;
	 int frontRight = 1;
	 int rearLeft = 1;
	 int rearLeftMid = 1;
	 int rearRightMid = 1;
	 int rearRight = 1;
	 
     void onClkMonitorRadarData(){
    	frontLeft = makeRadarTestData(frontLeft);
 	    frontLeftMid = makeRadarTestData(frontLeftMid);
 	    frontRightMid = makeRadarTestData(frontRightMid);
 	    frontRight = makeRadarTestData(frontRight);
 	    
 	    rearLeft = makeRadarTestData(rearLeft);
 	    rearLeftMid = makeRadarTestData(rearLeftMid);
 	    rearRightMid = makeRadarTestData(rearRightMid);
 	    rearRight = makeRadarTestData(rearRight);
 	    ViewModel.getIns().setViewProperty(R.id.radar_front_left, frontLeft);
 	    ViewModel.getIns().setViewProperty(R.id.radar_front_left_mid, frontLeftMid);
 	    ViewModel.getIns().setViewProperty(R.id.radar_front_right_mid,frontRightMid);
 	    ViewModel.getIns().setViewProperty(R.id.radar_front_right, frontRight);
 	    ViewModel.getIns().setViewProperty(R.id.radar_rear_left, rearLeft);
 	    ViewModel.getIns().setViewProperty(R.id.radar_rear_left_mid, rearLeftMid);
 	    ViewModel.getIns().setViewProperty(R.id.radar_rear_right_mid, rearRightMid);
 	    ViewModel.getIns().setViewProperty(R.id.radar_rear_right, rearRight);
     }
     
     int makeRadarTestData(int level){
    	 Log.d(tag, "makeRadar data"+level);
    	 level++;
    	 if(level > 7) level = 0;
    	 return level;
     }
     
}
